package com.tinama.jedis01.lock8;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.stream.Collectors;

/**
 * @author lgc
 * @createDate 2020/10/13 - 15:18
 */
public class Test2 {
    public static void main(String[] args){
//        List<String> list = Collections.synchronizedList(new ArrayList<>());
        List<String> list = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            new Thread(()->{
                list.add(UUID.randomUUID().toString().substring(0,5));
                System.out.println(Thread.currentThread().getName()+list);

            },"线程"+i+":").start();

        }
//        new ConcurrentHashMap<>();
//        Set set = new HashSet();
//        for (int i = 1; i <= 30; i++) {
//            new Thread(()->{
//                set.add(UUID.randomUUID().toString().substring(0,5));
//                System.out.println(Thread.currentThread().getName()+set);
//
//            },"线程"+i+":").start();
//
//        }


//        CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList();
//        copyOnWriteArrayList.add(1);
//        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
//        objectObjectHashMap.put(1,2);
//        new CopyOnWriteArraySet<>().add(2);
//        List<Integer> integers = Arrays.asList(1, 8, 6, 4, 6, 8, 3);
//        ArrayList<Integer> integers1 = new ArrayList<>(integers);
//        Iterator<Integer> iterator = integers1.iterator();
//        while (iterator.hasNext()){
//            Integer next = iterator.next();
//            if (next == 6){
//                iterator.remove();
//            }
//        }
//        System.out.println(integers1);

//        integers = Collections.synchronizedList(integers);
//        for (int i = 0,a=integers1.size();i < a; i++) {
//            if (integers1.get(i)==6){
//                integers1.remove(i);
//            }
//        }
//        System.out.println(integers1);
    }
}
